/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.desk.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.desk.entity.Collect;
import org.springblade.desk.enums.CollectCategoryEnum;
import org.springblade.desk.enums.CollectContentTypeEnum;
import org.springblade.desk.enums.CollectSubCategoryEnum;
import org.springblade.desk.vo.CollectVO;

/**
 * Notice包装类,返回视图层所需的字段
 *
 * @author Chill
 */
public class CollectWrapper extends BaseEntityWrapper<Collect, CollectVO> {

	public static CollectWrapper build() {
		return new CollectWrapper();
	}

	@Override
	public CollectVO entityVO(Collect collect) {
	    CollectVO collectVO = new CollectVO();
	    collectVO.setId(collect.getId());
	    collectVO.setTitle(collect.getTitle());
	    collectVO.setSubTitle(collect.getSubTitle());
	    collectVO.setCategory(collect.getCategory());
	    collectVO.setSubCategory(collect.getSubCategory());
	    collectVO.setContentType(collect.getContentType());
	    collectVO.setContent(collect.getContent());
	    collectVO.setRemark(collect.getRemark());
	    collectVO.setCreateDept(collect.getCreateDept());
	    collectVO.setCreateUser(collect.getCreateUser());
	    collectVO.setCreateTime(collect.getCreateTime());
	    collectVO.setUpdateUser(collect.getUpdateUser());
	    collectVO.setUpdateTime(collect.getUpdateTime());
	    collectVO.setStatus(collect.getStatus());
	    collectVO.setIsDeleted(collect.getIsDeleted());
		collectVO.setCategoryName(CollectCategoryEnum.getDescByType(collect.getCategory()));
		collectVO.setSubCategoryName(CollectSubCategoryEnum.getDescByType(collect.getSubCategory()));
		collectVO.setContentTypeName(CollectContentTypeEnum.getDescByType(collect.getContentType()));
//		R<String> dictCategory = dictClient.getValue("collect.category", collectVO.getCategory());
//		R<String> dictSubCategory = dictClient.getValue("collect.subCategory", collectVO.getSubCategory());
//		R<String> dictContentType = dictClient.getValue("collect.contentType", collectVO.getContentType());
//		if (dictCategory.isSuccess()) {
//			collectVO.setCategoryName(dictCategory.getData());
//		}
//		if (dictSubCategory.isSuccess()) {
//			collectVO.setSubCategoryName(dictSubCategory.getData());
//		}
//		if (dictContentType.isSuccess()) {
//			collectVO.setContentTypeName(dictContentType.getData());
//		}
		return collectVO;
	}

}
